﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Net;
using System.ServiceModel.DomainServices.Client;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using GalaSoft.MvvmLight;
using System.Linq;


namespace AR.Entities
{
    public  class CANDIDATClient : Entity
    {
        private string _cvpath;
        [Required(ErrorMessage="Cv Obligatoire")]
        
        public string CvPath
        {
            get
            {
                return _cvpath;
            }
            set
            {
                _cvpath = value;
                RaisePropertyChanged("CvPath");

            }
        }
        private Nullable<global::System.Int32> _sALAIRE_DEMANDE;
        [Required(ErrorMessage = "Requis")]
        [RegularExpression(@"^[0-9]\d*$", ErrorMessage = "Salaire Invalide")]
        public Nullable<global::System.Int32> SALAIRE_DEMANDE
        {
            get
            {
                return _sALAIRE_DEMANDE;
            }
            set
            {
                _sALAIRE_DEMANDE = value;
                RaisePropertyChanged("SALAIRE_DEMANDE");

            }
        }
        private Nullable<global::System.Int32> _sALAIRE_ACTUELLE;
        [Required(ErrorMessage = "Requis")]
        [RegularExpression(@"^[0-9]\d*$", ErrorMessage = "Salaire Invalide")]
        public Nullable<global::System.Int32> SALAIRE_ACTUELLE
        {
            get
            {
                return _sALAIRE_ACTUELLE;
            }
            set
            {
                _sALAIRE_ACTUELLE = value;
                RaisePropertyChanged("SALAIRE_ACTUELLE");

            }
        }


        private global::System.String _nOM;
        [Required(ErrorMessage = "Requis")]
        public global::System.String NOM
        {
            get
            {
                return _nOM;
            }
            set
            {
                _nOM = value.ToUpper();
                RaisePropertyChanged("NOM");

            } 
        }


        private global::System.String _pRENOM;
        [Required(ErrorMessage = "Requis")]
        public global::System.String PRENOM
        {
            get
            {
                return _pRENOM;
            }
             set 
            { 
                if (String.IsNullOrEmpty(value)) 
                    _pRENOM = value; 
                else 
                    _pRENOM = value.First().ToString().ToUpper() + value.Substring(1); 
                
                RaisePropertyChanged("PRENOM");   

            } 
        }
    

        private global::System.String _eMAIL;
        [Required(ErrorMessage = "Requis")]
        [RegularExpression(@"^(?("")("".+?(?<!\\)""@)|(([0-9a-z]((\.(?!\.))|[-!#\$%&'\*\+/=\?\^`\{\}\|~\w])*)(?<=[0-9a-z])@))(?(\[)(\[(\d{1,3}\.){3}\d{1,3}\])|(([0-9a-z][-\w]*[0-9a-z]*\.)+[a-z0-9][\-a-z0-9]{0,22}[a-z0-9]))$"
            , ErrorMessage = "Format Email Invalide")]
        public global::System.String EMAIL
        {
            get
            {
                return _eMAIL;
            }
            set
            {
                if (String.IsNullOrEmpty(value))
                    _eMAIL = value;
                else
                    _eMAIL = value.ToLower();
                RaisePropertyChanged("EMAIL");
            }
        }
        private global::System.String _tEL;
        [Required(ErrorMessage = "Requis")]
        [RegularExpression(@"\d{10}", ErrorMessage = "Format Invalide(ex:0615478945)")]
        public global::System.String TEL
        {
            get
            {
                return _tEL;
            }
            set
            {
                _tEL = value;
                RaisePropertyChanged("TEL");

            }
        }

        private int? _pREAVIS;
        [Required(ErrorMessage = "Requis")]
        [RegularExpression(@"^[0-9]\d*$", ErrorMessage = "Préavis Invalide")]
        public int? PREAVIS
        {
            get
            {
                return _pREAVIS;
            }
            set
            {
                _pREAVIS = value;
                RaisePropertyChanged("PREAVIS");

            }
        }

        public global::System.String _dERNIER_EMPLOYEUR;
       // [Required(ErrorMessage = "Requis")]
        public global::System.String DERNIER_EMPLOYEUR
        {
            get
            {
                return _dERNIER_EMPLOYEUR;
            }
            set
            {
                _dERNIER_EMPLOYEUR = value;
                RaisePropertyChanged("DERNIER_EMPLOYEUR");

            }
        }  
        private int? _id_Test;

        [Required(ErrorMessage = "Requis")]
        [RegularExpression(@"^[1-9]\d*$", ErrorMessage = "vous devez choisir un Test")]
        public int? Id_Test
        {
            get
            {
                return _id_Test;
            }
            set
            {
                _id_Test = value;
                RaisePropertyChanged("Id_Test");

            }
        }
        private int? _idPoste;
        [Required(ErrorMessage = "Requis")]
        [RegularExpression(@"^[1-9]\d*$", ErrorMessage = "vous devez choisir un Poste")]
        public int? IdPoste
        {
            get
            {
                return _idPoste;
            }
            set
            {
                _idPoste = value;
                RaisePropertyChanged("IdPoste");

            }
        }
        private int? _idProjet;
        [Required(ErrorMessage = "Requis")]
        [RegularExpression(@"^[1-9]\d*$", ErrorMessage = "vous devez choisir un Projet")]
        public int? IdProjet
        {
            get
            {
                return _idProjet;
            }
            set
            {
                _idProjet = value;
                RaisePropertyChanged("IdProjet");

            }
        }
        private int? _idPractice;
        [Required(ErrorMessage = "Requis")]
        [RegularExpression(@"^[1-9]\d*$", ErrorMessage = "vous devez choisir une Practice")]
        public int? IdPractice
        {
            get
            {
                return _idPractice;
            }
            set
            {
                _idPractice = value;
                RaisePropertyChanged("IdPractice");

            }
        }
        private decimal? _gCM_ESTIMEE_RH;
        [Required(ErrorMessage = "Requis")]
        public decimal? GCM_ESTIMEE_RH
        {
            get
            {
                return _gCM_ESTIMEE_RH;
            }
            set
            {
                _gCM_ESTIMEE_RH = value;
                RaisePropertyChanged("GCM_ESTIMEE_RH");

            }
        }

        public bool ValidateCandidat(ValidationContext validationContext)
        {
            //Clear Previous valiadtion.
            ValidationErrors.Clear();

            IDictionary<object, object> dictionaryItems = null;
            ValidationContext employeeValidationContext = new ValidationContext(this, validationContext, dictionaryItems);
            ICollection<ValidationResult> employeeValidationResults = new List<ValidationResult>();

            //Use tryValidateobject to validate
            if (Validator.TryValidateObject(this, employeeValidationContext, employeeValidationResults, true) == false)
            {
                //Adding Validation result to validation error
                foreach (ValidationResult validationError in employeeValidationResults)
                {
                    ValidationErrors.Add(validationError);
                }
                return false;
            }

            return true;
        }
   
      
        
    }
}
